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

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

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

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

m = A("m")
j = B("j")
c = C("c")
l = D("l")
n = D("n")
b = A("b")

m.o = b
j.v = c
j.y = n
j.q = m
c.o = n
c.x = m
l.v = n
n.v = l
b.o = m
assert m.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
c = C("c")
l = D("l")
n = D("n")
b = A("b")

m.o = b
j.v = c
j.y = n
j.q = m
c.o = n
c.x = m
l.v = n
n.v = l
b.o = m
assert m.o.o.o.o.o.txt == "b"