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

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

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

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

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

j.r = a
j.w = l
g.q = j
g.z = b
g.r = b
b.s = l
f.r = n
f.x = j
f.v = j
a.r = j
a.w = l
n.r = f
n.x = j
n.v = a
c.q = a
c.z = b
c.r = b
k.q = j
k.z = b
k.r = b
l.r = f
l.x = j
l.v = a
assert k.q.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: D = None
        self.txt = txt

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

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

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

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

j.r = a
j.w = l
g.q = j
g.z = b
g.r = b
b.s = l
f.r = n
f.x = j
f.v = j
a.r = j
a.w = l
n.r = f
n.x = j
n.v = a
c.q = a
c.z = b
c.r = b
k.q = j
k.z = b
k.r = b
l.r = f
l.x = j
l.v = a
assert k.q.r.r.r.txt == "a"