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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: A = None
        self.txt = txt

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

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

c.t = d
c.x = e
c.r = m
m.y = h
m.o = h
m.u = g
e.o = m
e.x = g
h.z = g
h.y = m
g.t = c
g.x = e
g.r = m
d.t = c
d.x = e
d.r = m
assert m.u.t.x.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.x: C = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: A = None
        self.txt = txt

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

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

c.t = d
c.x = e
c.r = m
m.y = h
m.o = h
m.u = g
e.o = m
e.x = g
h.z = g
h.y = m
g.t = c
g.x = e
g.r = m
d.t = c
d.x = e
d.r = m
assert m.u.t.x.o.u.txt == "g"