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

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

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

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

a = A("a")
b = B("b")
m = C("m")
n = D("n")
h = C("h")

a.z = n
a.y = n
b.y = h
b.u = h
b.t = a
b.z = a
m.y = h
n.p = a
n.o = a
n.t = b
n.r = m
h.y = m
assert m.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: D = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
m = C("m")
n = D("n")
h = C("h")

a.z = n
a.y = n
b.y = h
b.u = h
b.t = a
b.z = a
m.y = h
n.p = a
n.o = a
n.t = b
n.r = m
h.y = m
assert m.y.y.y.txt == "h"