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

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

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

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

k = A("k")
b = B("b")
m = C("m")
f = D("f")
e = B("e")
j = D("j")
l = C("l")
g = C("g")
c = A("c")
d = B("d")

k.u = e
k.v = e
k.r = j
k.q = c
b.z = c
m.t = b
f.q = g
f.s = b
e.z = c
j.q = m
j.s = b
l.t = e
g.t = d
c.u = e
c.r = f
c.v = d
c.q = k
d.z = c
assert j.s.z.v.z.q.r.q.t.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: D = None
        self.v: B = None
        self.q: A = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
m = C("m")
f = D("f")
e = B("e")
j = D("j")
l = C("l")
g = C("g")
c = A("c")
d = B("d")

k.u = e
k.v = e
k.r = j
k.q = c
b.z = c
m.t = b
f.q = g
f.s = b
e.z = c
j.q = m
j.s = b
l.t = e
g.t = d
c.u = e
c.r = f
c.v = d
c.q = k
d.z = c
assert j.s.z.v.z.q.r.q.t.z.r.txt == "f"