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

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

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

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

d = A("d")
c = B("c")
l = C("l")
n = D("n")
h = B("h")
g = C("g")
b = D("b")
f = A("f")

d.o = c
d.q = b
d.v = h
d.w = h
c.t = d
c.o = b
c.r = l
c.x = h
l.u = d
l.x = g
l.p = f
n.t = h
n.q = b
h.t = d
h.o = b
h.r = l
h.x = c
g.u = d
g.x = l
g.p = f
b.t = c
b.q = n
f.o = h
f.q = n
f.v = c
f.w = c
assert d.v.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: D = None
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
l = C("l")
n = D("n")
h = B("h")
g = C("g")
b = D("b")
f = A("f")

d.o = c
d.q = b
d.v = h
d.w = h
c.t = d
c.o = b
c.r = l
c.x = h
l.u = d
l.x = g
l.p = f
n.t = h
n.q = b
h.t = d
h.o = b
h.r = l
h.x = c
g.u = d
g.x = l
g.p = f
b.t = c
b.q = n
f.o = h
f.q = n
f.v = c
f.w = c
assert d.v.x.x.txt == "h"