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

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

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

a = A("a")
c = B("c")
e = C("e")
k = C("k")
h = C("h")
l = C("l")
f = B("f")
n = C("n")
m = A("m")

a.y = m
a.v = c
c.v = f
e.u = f
e.v = m
k.u = f
k.v = a
h.u = f
h.v = a
l.u = f
l.v = m
f.v = c
n.u = f
n.v = m
m.y = a
m.v = f
assert h.u.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
e = C("e")
k = C("k")
h = C("h")
l = C("l")
f = B("f")
n = C("n")
m = A("m")

a.y = m
a.v = c
c.v = f
e.u = f
e.v = m
k.u = f
k.v = a
h.u = f
h.v = a
l.u = f
l.v = m
f.v = c
n.u = f
n.v = m
m.y = a
m.v = f
assert h.u.v.v.v.v.txt == "f"