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

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

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

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

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

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

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

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

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

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

f.t = g
g.q = l
g.z = f
g.r = f
g.w = c
j.u = c
j.x = c
j.s = g
j.r = l
l.r = c
l.y = c
d.q = l
d.w = l
d.z = f
d.r = f
c.r = l
c.y = l
n.q = l
n.z = f
n.r = f
n.w = c
assert j.s.q.r.r.txt == "l"