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

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

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

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

j = A("j")
c = B("c")
l = C("l")
g = D("g")

j.o = c
j.x = l
c.r = l
c.s = l
l.v = g
l.q = g
l.x = g
l.t = c
g.q = l
assert c.s.x.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: C = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
l = C("l")
g = D("g")

j.o = c
j.x = l
c.r = l
c.s = l
l.v = g
l.q = g
l.x = g
l.t = c
g.q = l
assert c.s.x.q.v.txt == "g"