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

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

c = A("c")
i = B("i")
b = B("b")
a = A("a")
e = B("e")
m = A("m")
h = A("h")

c.u = b
i.x = b
i.r = h
b.x = i
b.r = a
a.u = e
e.x = b
e.r = m
m.u = e
h.u = b
assert i.x.r.u.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
b = B("b")
a = A("a")
e = B("e")
m = A("m")
h = A("h")

c.u = b
i.x = b
i.r = h
b.x = i
b.r = a
a.u = e
e.x = b
e.r = m
m.u = e
h.u = b
assert i.x.r.u.x.x.txt == "i"