class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: C = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: C = None
        self.o: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: A = None
        self.txt = txt

a = A("a")
c = B("c")
b = C("b")
f = D("f")
e = E("e")
m = F("m")
d = G("d")
i = F("i")

a.p = e
c.r = b
b.v = c
b.y = c
f.r = b
f.y = d
f.o = c
e.v = c
e.t = b
e.w = m
m.z = b
m.r = b
m.o = f
d.p = a
d.w = a
i.z = b
i.r = b
i.o = f
assert e.w.z.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: C = None
        self.w: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: C = None
        self.o: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: A = None
        self.txt = txt

a = A("a")
c = B("c")
b = C("b")
f = D("f")
e = E("e")
m = F("m")
d = G("d")
i = F("i")

a.p = e
c.r = b
b.v = c
b.y = c
f.r = b
f.y = d
f.o = c
e.v = c
e.t = b
e.w = m
m.z = b
m.r = b
m.o = f
d.p = a
d.w = a
i.z = b
i.r = b
i.o = f
assert e.w.z.y.r.y.r.txt == "b"