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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

k = A("k")
b = B("b")
n = C("n")
f = D("f")
m = E("m")
g = D("g")

k.o = f
b.s = g
n.u = k
n.y = k
f.z = k
m.r = g
g.z = k
assert k.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

k = A("k")
b = B("b")
n = C("n")
f = D("f")
m = E("m")
g = D("g")

k.o = f
b.s = g
n.u = k
n.y = k
f.z = k
m.r = g
g.z = k
assert k.o.z.o.z.txt == "k"