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

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

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

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

g = A("g")
j = B("j")
c = C("c")
n = D("n")
a = C("a")
f = A("f")
b = B("b")
h = D("h")
m = A("m")
k = A("k")

g.r = j
g.s = c
g.q = f
j.t = m
j.x = b
c.z = j
c.w = j
c.u = n
c.t = k
n.w = c
n.p = c
n.r = f
n.o = j
a.z = b
a.u = n
a.t = g
a.w = j
f.r = b
f.s = c
f.q = m
b.t = f
b.x = j
h.w = a
h.r = f
h.o = b
h.p = c
m.r = j
m.s = a
m.q = g
k.r = j
k.s = a
k.q = f
assert a.z.x.x.t.s.u.r.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: C = None
        self.q: A = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
c = C("c")
n = D("n")
a = C("a")
f = A("f")
b = B("b")
h = D("h")
m = A("m")
k = A("k")

g.r = j
g.s = c
g.q = f
j.t = m
j.x = b
c.z = j
c.w = j
c.u = n
c.t = k
n.w = c
n.p = c
n.r = f
n.o = j
a.z = b
a.u = n
a.t = g
a.w = j
f.r = b
f.s = c
f.q = m
b.t = f
b.x = j
h.w = a
h.r = f
h.o = b
h.p = c
m.r = j
m.s = a
m.q = g
k.r = j
k.s = a
k.q = f
assert a.z.x.x.t.s.u.r.q.q.txt == "g"