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

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

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

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

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

a.s = c
a.x = g
g.v = f
g.r = d
g.q = d
g.t = d
j.q = f
j.x = b
d.v = b
d.u = b
d.t = a
d.s = f
b.s = c
b.x = c
n.q = j
n.x = a
f.q = n
f.x = a
c.v = n
c.r = d
c.q = d
c.t = d
assert f.x.x.r.s.x.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

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

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

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

a.s = c
a.x = g
g.v = f
g.r = d
g.q = d
g.t = d
j.q = f
j.x = b
d.v = b
d.u = b
d.t = a
d.s = f
b.s = c
b.x = c
n.q = j
n.x = a
f.q = n
f.x = a
c.v = n
c.r = d
c.q = d
c.t = d
assert f.x.x.r.s.x.x.q.txt == "d"