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

class B:
    def __init__(self, txt: str):
        self.p: C = 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.u: A = None
        self.o: A = None
        self.x: B = None
        self.r: B = None
        self.txt = txt

m = A("m")
f = B("f")
i = C("i")
d = D("d")
b = C("b")
g = A("g")

m.z = f
m.y = i
m.u = g
m.t = d
f.p = i
i.y = g
d.u = m
d.o = g
d.x = f
d.r = f
b.y = g
g.z = f
g.y = b
g.u = m
g.t = d
assert m.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: C = None
        self.u: A = None
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = 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.u: A = None
        self.o: A = None
        self.x: B = None
        self.r: B = None
        self.txt = txt

m = A("m")
f = B("f")
i = C("i")
d = D("d")
b = C("b")
g = A("g")

m.z = f
m.y = i
m.u = g
m.t = d
f.p = i
i.y = g
d.u = m
d.o = g
d.x = f
d.r = f
b.y = g
g.z = f
g.y = b
g.u = m
g.t = d
assert m.y.y.u.txt == "m"