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

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

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

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

n = A("n")
b = B("b")
h = C("h")
c = D("c")
j = D("j")
d = B("d")
m = D("m")
i = A("i")
f = D("f")

n.r = i
n.x = j
b.v = n
b.y = i
h.t = i
h.w = j
c.q = h
c.o = h
c.s = d
c.u = m
j.q = h
j.o = h
j.s = d
j.u = m
d.v = i
d.y = i
m.q = h
m.o = h
m.s = b
m.u = c
i.r = n
i.x = f
f.q = h
f.o = h
f.s = d
f.u = c
assert f.s.v.r.r.x.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: D = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
h = C("h")
c = D("c")
j = D("j")
d = B("d")
m = D("m")
i = A("i")
f = D("f")

n.r = i
n.x = j
b.v = n
b.y = i
h.t = i
h.w = j
c.q = h
c.o = h
c.s = d
c.u = m
j.q = h
j.o = h
j.s = d
j.u = m
d.v = i
d.y = i
m.q = h
m.o = h
m.s = b
m.u = c
i.r = n
i.x = f
f.q = h
f.o = h
f.s = d
f.u = c
assert f.s.v.r.r.x.s.v.txt == "i"