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

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

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

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

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

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

c.x = f
c.u = g
l.r = i
f.x = n
f.u = n
h.r = c
i.x = n
i.u = c
j.r = g
a.x = c
a.u = n
n.x = f
n.u = c
g.x = a
g.u = i
assert g.u.x.u.u.u.x.u.txt == "c"