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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

m = A("m")
f = B("f")
c = C("c")
d = D("d")
e = D("e")
j = B("j")
g = C("g")

m.t = c
f.q = c
f.u = j
f.y = e
c.y = m
d.q = f
d.w = e
e.q = j
e.w = d
j.q = c
j.u = f
j.y = e
g.y = m
assert m.t.y.t.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

m = A("m")
f = B("f")
c = C("c")
d = D("d")
e = D("e")
j = B("j")
g = C("g")

m.t = c
f.q = c
f.u = j
f.y = e
c.y = m
d.q = f
d.w = e
e.q = j
e.w = d
j.q = c
j.u = f
j.y = e
g.y = m
assert m.t.y.t.y.t.y.txt == "m"