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

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

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

m = A("m")
d = B("d")
c = C("c")
l = A("l")
b = B("b")
e = C("e")
i = A("i")

m.u = c
m.p = c
m.x = i
d.r = b
d.v = b
d.z = i
c.v = b
c.r = b
l.u = c
l.p = c
l.x = i
b.r = d
b.v = d
b.z = i
e.v = d
e.r = d
i.u = e
i.p = e
i.x = l
assert i.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
c = C("c")
l = A("l")
b = B("b")
e = C("e")
i = A("i")

m.u = c
m.p = c
m.x = i
d.r = b
d.v = b
d.z = i
c.v = b
c.r = b
l.u = c
l.p = c
l.x = i
b.r = d
b.v = d
b.z = i
e.v = d
e.r = d
i.u = e
i.p = e
i.x = l
assert i.x.x.x.txt == "l"