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

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

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

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

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

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

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

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

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

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

f.s = b
f.y = b
f.q = c
f.p = c
a.t = b
a.r = n
b.s = j
b.w = j
b.x = a
b.r = k
k.t = f
j.s = m
j.w = m
j.x = n
j.r = k
m.s = j
m.w = j
m.x = n
m.r = k
c.s = j
c.y = j
c.q = f
c.p = f
n.t = b
n.r = a
assert a.r.r.r.txt == "n"