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

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

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

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

g = A("g")
a = B("a")
c = C("c")
b = D("b")
f = B("f")
d = A("d")

g.x = c
g.p = c
g.w = d
g.y = f
a.u = c
a.s = c
a.q = g
a.v = b
c.w = d
b.o = f
b.v = f
f.u = c
f.s = c
f.q = d
f.v = b
d.x = c
d.p = c
d.w = g
d.y = a
assert b.v.v.o.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: A = None
        self.p: C = None
        self.y: B = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
c = C("c")
b = D("b")
f = B("f")
d = A("d")

g.x = c
g.p = c
g.w = d
g.y = f
a.u = c
a.s = c
a.q = g
a.v = b
c.w = d
b.o = f
b.v = f
f.u = c
f.s = c
f.q = d
f.v = b
d.x = c
d.p = c
d.w = g
d.y = a
assert b.v.v.o.u.w.txt == "d"