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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: B = None
        self.r: A = None
        self.w: C = None
        self.txt = txt

m = A("m")
b = B("b")
c = C("c")
g = D("g")
f = A("f")
l = A("l")

m.x = b
b.s = c
b.q = g
c.y = g
c.o = g
c.v = m
g.y = c
g.w = c
g.t = b
g.r = l
f.x = b
l.x = b
assert l.x.s.v.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: B = None
        self.r: A = None
        self.w: C = None
        self.txt = txt

m = A("m")
b = B("b")
c = C("c")
g = D("g")
f = A("f")
l = A("l")

m.x = b
b.s = c
b.q = g
c.y = g
c.o = g
c.v = m
g.y = c
g.w = c
g.t = b
g.r = l
f.x = b
l.x = b
assert l.x.s.v.x.q.txt == "g"