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

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

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

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

b = A("b")
f = B("f")
g = C("g")
a = D("a")
j = A("j")
k = D("k")
i = A("i")
e = A("e")

b.u = k
b.p = k
f.y = j
f.o = g
g.z = b
g.u = f
g.y = f
a.p = f
j.u = k
j.p = k
k.p = f
i.u = k
i.p = k
e.u = a
e.p = k
assert k.p.o.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: D = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
g = C("g")
a = D("a")
j = A("j")
k = D("k")
i = A("i")
e = A("e")

b.u = k
b.p = k
f.y = j
f.o = g
g.z = b
g.u = f
g.y = f
a.p = f
j.u = k
j.p = k
k.p = f
i.u = k
i.p = k
e.u = a
e.p = k
assert k.p.o.u.y.u.txt == "k"