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

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

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

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

k = A("k")
b = B("b")
c = C("c")
h = D("h")
i = C("i")
m = C("m")
f = C("f")

k.o = f
k.z = b
b.z = h
b.y = h
b.o = h
b.r = k
c.t = k
h.r = k
h.y = b
h.z = f
i.t = k
m.t = k
f.t = k
assert b.o.y.r.z.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: B = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
c = C("c")
h = D("h")
i = C("i")
m = C("m")
f = C("f")

k.o = f
k.z = b
b.z = h
b.y = h
b.o = h
b.r = k
c.t = k
h.r = k
h.y = b
h.z = f
i.t = k
m.t = k
f.t = k
assert b.o.y.r.z.y.r.txt == "k"