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

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

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

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

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

c.t = i
c.r = g
n.v = j
n.o = j
n.s = j
n.r = c
f.x = i
f.z = h
f.r = n
j.w = b
j.o = n
g.w = b
g.o = i
b.x = n
b.z = f
b.r = i
i.v = g
i.o = g
i.r = c
i.s = j
h.x = n
h.r = n
h.z = b
assert g.o.v.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

c.t = i
c.r = g
n.v = j
n.o = j
n.s = j
n.r = c
f.x = i
f.z = h
f.r = n
j.w = b
j.o = n
g.w = b
g.o = i
b.x = n
b.z = f
b.r = i
i.v = g
i.o = g
i.r = c
i.s = j
h.x = n
h.r = n
h.z = b
assert g.o.v.o.r.txt == "c"