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

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

d = A("d")
a = B("a")
c = A("c")
b = A("b")
e = A("e")
k = B("k")

d.u = e
d.v = k
a.y = k
a.z = c
c.u = e
c.v = k
b.u = c
b.v = a
e.u = c
e.v = k
k.y = a
k.z = e
assert e.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: B = None
        self.txt = txt

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

d = A("d")
a = B("a")
c = A("c")
b = A("b")
e = A("e")
k = B("k")

d.u = e
d.v = k
a.y = k
a.z = c
c.u = e
c.v = k
b.u = c
b.v = a
e.u = c
e.v = k
k.y = a
k.z = e
assert e.u.u.u.u.u.txt == "c"