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

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

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

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

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

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

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

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

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

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

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