class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: D = None
        self.txt = txt

b = A("b")
f = B("f")
e = C("e")
j = D("j")
g = B("g")
i = A("i")
l = D("l")

b.r = j
f.q = i
f.t = e
f.s = e
e.s = f
j.r = g
j.t = l
g.q = b
g.t = e
g.s = e
i.r = l
l.r = f
l.t = j
assert i.r.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: D = None
        self.txt = txt

b = A("b")
f = B("f")
e = C("e")
j = D("j")
g = B("g")
i = A("i")
l = D("l")

b.r = j
f.q = i
f.t = e
f.s = e
e.s = f
j.r = g
j.t = l
g.q = b
g.t = e
g.s = e
i.r = l
l.r = f
l.t = j
assert i.r.r.t.s.txt == "f"