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

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

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

b = A("b")
d = B("d")
e = C("e")
h = A("h")
m = B("m")

b.v = m
d.r = m
d.v = m
d.o = e
e.x = m
h.v = d
m.r = d
m.v = d
m.o = e
assert e.x.o.x.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
e = C("e")
h = A("h")
m = B("m")

b.v = m
d.r = m
d.v = m
d.o = e
e.x = m
h.v = d
m.r = d
m.v = d
m.o = e
assert e.x.o.x.o.x.txt == "m"