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

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

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

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

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

m.r = b
m.x = c
m.v = g
b.y = e
b.v = e
b.r = e
g.o = d
c.r = d
c.t = j
c.p = j
f.r = b
f.x = j
f.v = d
e.y = b
e.v = b
e.r = b
i.r = b
i.x = j
i.v = g
d.o = g
j.r = d
j.t = c
j.p = c
assert j.t.p.r.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.v: C = None
        self.txt = txt

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

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

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

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

m.r = b
m.x = c
m.v = g
b.y = e
b.v = e
b.r = e
g.o = d
c.r = d
c.t = j
c.p = j
f.r = b
f.x = j
f.v = d
e.y = b
e.v = b
e.r = b
i.r = b
i.x = j
i.v = g
d.o = g
j.r = d
j.t = c
j.p = c
assert j.t.p.r.o.o.o.o.o.o.txt == "d"