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

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

c = A("c")
i = B("i")
d = B("d")
f = B("f")
j = B("j")
e = B("e")
l = B("l")
h = A("h")
a = A("a")
g = B("g")

c.v = g
c.u = i
i.r = l
d.r = e
f.r = j
j.r = e
e.r = g
l.r = j
h.v = f
h.u = j
a.v = i
a.u = d
g.r = f
assert i.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
d = B("d")
f = B("f")
j = B("j")
e = B("e")
l = B("l")
h = A("h")
a = A("a")
g = B("g")

c.v = g
c.u = i
i.r = l
d.r = e
f.r = j
j.r = e
e.r = g
l.r = j
h.v = f
h.u = j
a.v = i
a.u = d
g.r = f
assert i.r.r.r.r.r.txt == "f"