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

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

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

m = A("m")
e = B("e")
d = C("d")
g = B("g")
b = C("b")
n = B("n")
c = A("c")
k = C("k")

m.u = c
m.y = c
e.y = k
e.w = b
d.z = c
d.t = m
g.y = k
g.w = k
b.z = m
b.t = m
n.y = d
n.w = k
c.u = m
c.y = m
k.z = c
k.t = c
assert k.t.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: A = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
d = C("d")
g = B("g")
b = C("b")
n = B("n")
c = A("c")
k = C("k")

m.u = c
m.y = c
e.y = k
e.w = b
d.z = c
d.t = m
g.y = k
g.w = k
b.z = m
b.t = m
n.y = d
n.w = k
c.u = m
c.y = m
k.z = c
k.t = c
assert k.t.y.y.y.txt == "m"