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

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

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

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

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

b.v = k
d.u = n
d.y = i
a.r = b
a.v = b
a.t = b
a.u = c
c.t = b
c.s = a
c.q = k
n.v = k
k.r = n
k.v = n
k.u = c
k.t = b
f.u = n
f.y = c
m.u = n
m.y = c
i.t = b
i.s = a
i.q = a
assert i.t.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

b.v = k
d.u = n
d.y = i
a.r = b
a.v = b
a.t = b
a.u = c
c.t = b
c.s = a
c.q = k
n.v = k
k.r = n
k.v = n
k.u = c
k.t = b
f.u = n
f.y = c
m.u = n
m.y = c
i.t = b
i.s = a
i.q = a
assert i.t.v.r.txt == "n"