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

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

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

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

c = A("c")
a = B("a")
h = C("h")
n = D("n")
g = B("g")
d = A("d")
k = B("k")
f = D("f")
j = B("j")

c.r = d
c.v = a
a.p = h
a.y = j
h.t = d
n.x = d
n.z = h
g.p = h
g.y = j
d.r = c
d.v = g
k.p = h
k.y = a
f.x = c
f.z = h
j.p = h
j.y = k
assert a.p.t.v.y.p.t.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
h = C("h")
n = D("n")
g = B("g")
d = A("d")
k = B("k")
f = D("f")
j = B("j")

c.r = d
c.v = a
a.p = h
a.y = j
h.t = d
n.x = d
n.z = h
g.p = h
g.y = j
d.r = c
d.v = g
k.p = h
k.y = a
f.x = c
f.z = h
j.p = h
j.y = k
assert a.p.t.v.y.p.t.r.r.r.txt == "c"