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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.txt = txt

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

f = A("f")
c = B("c")
d = C("d")
a = D("a")
j = B("j")
l = C("l")

f.t = a
f.u = a
f.s = d
c.t = f
d.w = a
d.q = l
a.q = f
j.t = f
l.w = a
l.q = d
assert c.t.t.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: C = None
        self.u: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.txt = txt

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

f = A("f")
c = B("c")
d = C("d")
a = D("a")
j = B("j")
l = C("l")

f.t = a
f.u = a
f.s = d
c.t = f
d.w = a
d.q = l
a.q = f
j.t = f
l.w = a
l.q = d
assert c.t.t.q.u.txt == "a"