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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: D = None
        self.u: D = None
        self.r: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: B = None
        self.txt = txt

a = A("a")
g = B("g")
c = C("c")
j = D("j")
l = B("l")
f = B("f")
h = A("h")
k = B("k")

a.r = h
a.q = j
a.t = c
g.p = j
g.w = j
g.u = j
g.r = l
c.z = h
c.u = h
c.v = k
j.r = a
j.p = l
l.p = j
l.w = j
l.u = j
l.r = g
f.p = j
f.w = j
f.u = j
f.r = k
h.r = a
h.q = j
h.t = c
k.p = j
k.w = j
k.u = j
k.r = g
assert g.w.r.r.r.r.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: D = None
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: D = None
        self.u: D = None
        self.r: B = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: B = None
        self.txt = txt

a = A("a")
g = B("g")
c = C("c")
j = D("j")
l = B("l")
f = B("f")
h = A("h")
k = B("k")

a.r = h
a.q = j
a.t = c
g.p = j
g.w = j
g.u = j
g.r = l
c.z = h
c.u = h
c.v = k
j.r = a
j.p = l
l.p = j
l.w = j
l.u = j
l.r = g
f.p = j
f.w = j
f.u = j
f.r = k
h.r = a
h.q = j
h.t = c
k.p = j
k.w = j
k.u = j
k.r = g
assert g.w.r.r.r.r.t.z.txt == "h"