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

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

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

d = A("d")
c = B("c")
m = C("m")
e = C("e")
j = B("j")

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

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

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

d = A("d")
c = B("c")
m = C("m")
e = C("e")
j = B("j")

d.v = j
c.x = d
c.o = j
c.v = e
m.x = d
e.x = d
j.x = d
j.o = c
j.v = m
assert e.x.v.v.txt == "m"