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

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

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

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

b = A("b")
g = B("g")
d = C("d")
m = D("m")
e = C("e")
l = B("l")
k = A("k")
f = A("f")

b.w = e
b.v = e
b.s = d
b.r = k
g.s = l
g.t = l
g.p = d
d.x = l
m.z = l
m.q = g
m.s = b
e.x = l
l.s = g
l.t = g
l.p = d
k.w = d
k.s = d
k.v = e
k.r = b
f.w = e
f.v = e
f.s = e
f.r = b
assert g.t.p.x.t.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: C = None
        self.s: C = None
        self.r: A = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
d = C("d")
m = D("m")
e = C("e")
l = B("l")
k = A("k")
f = A("f")

b.w = e
b.v = e
b.s = d
b.r = k
g.s = l
g.t = l
g.p = d
d.x = l
m.z = l
m.q = g
m.s = b
e.x = l
l.s = g
l.t = g
l.p = d
k.w = d
k.s = d
k.v = e
k.r = b
f.w = e
f.v = e
f.s = e
f.r = b
assert g.t.p.x.t.p.x.p.txt == "d"