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

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

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

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

i = A("i")
g = B("g")
a = C("a")
j = D("j")
k = A("k")
m = A("m")
d = A("d")
n = B("n")
f = B("f")

i.x = a
i.r = d
i.t = j
g.y = n
a.o = j
a.p = f
j.y = k
j.r = k
j.q = i
j.v = a
k.x = a
k.r = m
k.t = j
m.x = a
m.r = k
m.t = j
d.x = a
d.r = i
d.t = j
n.y = f
f.y = g
assert d.r.x.o.q.t.r.r.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: A = None
        self.t: D = None
        self.txt = txt

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

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

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

i = A("i")
g = B("g")
a = C("a")
j = D("j")
k = A("k")
m = A("m")
d = A("d")
n = B("n")
f = B("f")

i.x = a
i.r = d
i.t = j
g.y = n
a.o = j
a.p = f
j.y = k
j.r = k
j.q = i
j.v = a
k.x = a
k.r = m
k.t = j
m.x = a
m.r = k
m.t = j
d.x = a
d.r = i
d.t = j
n.y = f
f.y = g
assert d.r.x.o.q.t.r.r.r.t.txt == "j"